package com.iefgames.cs.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.iefgames.cs.comet.CsComet;
import com.iefgames.cs.comet.UsComet;

public class Comet extends HttpServlet {
	
	private static Log logger = LogFactory.getLog(Comet.class); 
	
	public void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		Enumeration<String> names = request.getParameterNames();
		
		String name = null;
		ArrayList<String> params = new ArrayList<String>();
		while (names.hasMoreElements()) {
			params.add((name = names.nextElement()) + "=" + request.getParameter(name));
		}
		
		logger.info("------>" + request.getRequestURI() + " " + params.toString());
		
		//根据选择进行comet
		if (request.getParameter("sessionId") != null) {
			CsComet comet = new CsComet();
			comet.comet(request, response);
		} else {
			UsComet comet = new UsComet();
			comet.comet(request, response);
		}
	}
}
